/*
    模板函数的类外实现
*/
#include <iostream>

template <typename T1, typename T2>
class MyCalculator
{
private:
    T1 t1;
    T2 t2;

public:
    MyCalculator();
    MyCalculator(T1 t1, T2 t2);
    void showAddResult();
};

template <typename T1, typename T2>
MyCalculator<T1, T2>::MyCalculator()
{
    std::cout << "MyCalculator的有参构造调用了" << std::endl;
}

template <typename T1, typename T2>
MyCalculator<T1, T2>::MyCalculator(T1 t1, T2 t2) : t1(t1), t2(t2)
{
    std::cout << "MyCalculator 的无参数构造调用了" << std::endl;
}

template <typename T1, typename T2>
void MyCalculator<T1, T2>::showAddResult()
{
    std::cout << t1 + t2 << std::endl;
}

int main(int argc, char const *argv[])
{
    
    MyCalculator<double, double> cal{9.99, 3.14}; // 这儿的参数必须相同，实参是double 类型，模板类型也需要是double 类型，不能是int类型
    cal.showAddResult();
    return 0;
}
